function [diff,kappad_0,kappad_1,Ad_0,Ad_1,Ad_2] = mean_pd_LL(x , I , WC)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This code calculates the log-linearized coefficients for EIS ~= 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

kappad_1 = exp(x)/(exp(x) + 1);

kappad_0 = log(1 + exp(x)) - x * kappad_1;

Ad_2 = I.alpha/((1 - I.alpha) * kappad_1 - 1) ;

Ad_1 = (I.lambda - 1/I.psi + (I.lambda - 1) * kappad_1 * Ad_2)/(1 - (1 - I.nu + I.phi * I.nu) * kappad_1);

Ad_0 = (I.theta * log(I.delta) + (I.theta - 1) * WC.kappa_0 + (I.theta - 1) * (WC.kappa_1 - 1) * WC.A_0 + (I.theta - 1) * (1 - I.phi) * (1 - WC.kappa_1 + I.nu * WC.kappa_1) * I.mu * WC.A_1 ...
     + kappad_0 + (1 - I.phi) * (1 - kappad_1 + I.nu * kappad_1) * I.mu * Ad_1  + (kappad_1 * Ad_2 + 1) * I.alpha * I.mu_dc...
     + 0.5 * (kappad_1 * Ad_2 + 1)^2 * I.sigma_d^2 + 0.5 * (-I.gamma + I.lambda + kappad_1 * Ad_2 * (I.lambda - 1) + I.phi * I.nu *(kappad_1 * Ad_1 + (I.theta - 1) * WC.kappa_1 * WC.A_1))^2 * (1 + I.phi * I.nu) * I.sigma^2)/(1 - kappad_1) ;
 
 diff = x - Ad_0 - Ad_1 * I.phi * I.mu - Ad_2 * I.d_c_mean;
 
end
